package main 

import "fmt"

func QuickSort(arr []int) []int {

	if len(arr)<=1 {
		return arr
	}

	splitdata :=arr[0] //第一個數據 
	low :=make([]int,0,0)  //比我小的數據
	high :=make([]int,0,0) //比我大的數據
	mid :=make([]int,0,0) //與我一樣大的數據
	mid =append(mid,splitdata) //加入一個

	for i:=1;i<len(arr);i++ {
		if arr[i]<splitdata {
			low=append(low,arr[i])
		}else if arr[i]>splitdata {
			high=append(high,arr[i])
		}else {
			mid=append(mid,arr[i])
		}
	}

	low,high =QuickSort(low),QuickSort(high)

	myarr :=append(append(low,mid...),high...)

	return myarr
}


func main(){
	arr :=[]int{1,9,10,30,2,5,45,8,63,234,12}
	fmt.Println(QuickSort(arr))
}